
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="__PUBLIC__/css/common.css">
<link rel="stylesheet" href="__PUBLIC__/css/main.css">
<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
<script type="text/javascript"
	src="__PUBLIC__/js/colResizable-1.3.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>

<script type="text/javascript" charset="utf-8"
	src="__PUBLIC__/ueditor1_4_3-utf8-php/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8"
	src="__PUBLIC__/ueditor1_4_3-utf8-php/ueditor.all.min.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8"
	src="__PUBLIC__/ueditor1_4_3-utf8-php/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
      $(function(){  
        $(".list_table").colResizable({
          liveDrag:true,
          gripInnerHtml:"<div class='grip'></div>", 
          draggingClass:"dragging", 
          minWidth:30
        }); 
        
      }); 
   </script>
<title>新增课程</title>
</head>
<body>
<!--
 登陆成功{{$_SESSION['user']['username']}}
 -->
<div id="forms" class="mt10">
<div class="box">
<div class="box_border">
<div class="box_center">
<form action="{{:U('/Course/courseAdd')}}" class="jqtransform" id="form"
	method="post" enctype="multipart/form-data">
<table class="form_table pt15 pb15" width="100%" border="0"
	cellpadding="0" cellspacing="0">
	<tr>
		<td class="td_right">机构名称:</td>
		<td class=""><select class="select" id='center_id'
			name="center_id">
			<!--<option value="0">---请选择---</option>-->
			<foreach name="centerList" item="fa">
			<!--<if condition="($fa.id eq $vo[center_id])">
		            			<option value="{{$fa['id']}}" selected>{{$fa['name']}}</option>
	            			<else/>-->
			<option value="{{$fa['id']}}">{{$fa['name']}}</option>
			<!--</if>-->
			</foreach>
		</select></td>
	</tr>
	<tr>
		<td class="td_right">课程分类:</td>
		<td class=""><select class="select" id='type' name="type">
			<!--<option value="0">---请选择---</option>-->
			<foreach name="centerTypeList" item="fa">
			<!--<if condition="($fa.id eq $vo[center_id])">
		            			<option value="{{$fa['id']}}" selected>{{$fa['name']}}</option>
	            			<else/>-->
			<option value="{{$fa['id']}}">{{$fa['course_type']}}</option>
			<!--</if>-->
			</foreach>
		</select></td>
	</tr>
	<tr>
		<td class="td_right">课程名称:</td>
		<td class=""><input type="text" name="course_name"
			class="input-text lh30" size="40"></td>
	</tr>
	<tr>
		<td class="td_right">二级课程:</td>
		<td><a href="javascript:();" class="btn btn-success"
			onclick="addCourse()">添加二级课程</a></td>
	</tr>
	<tr>
		<td class="td_right"></td>
		<td>
		<div id="courseDiv" class="span12"></div>
		</td>
	</tr>
	<tr>
		<td class="td_right">课程价格:</td>
		<td class=""><input type="text" name="price"
			class="input-text lh30" size="40"></td>
	</tr>
	<tr>
		<td class="td_right">搜班价格:</td>
		<td class=""><input type="text" name="sbprice"
			class="input-text lh30" size="40"></td>
	</tr>
	<tr>
		<td class="td_right">上传图片:</td>
		<td><a href="javascript:();" class="btn btn-success"
			onclick="addPic()">添加图片</a></td>
	</tr>
	<tr>
		<td class="td_right"></td>
		<td>
		<div id="picDiv" class="span12"></div>
		</td>
	</tr>
	<tr>
		<td class="td_right">报名须知:</td>
		<td class=""><script id="editor" name="editor" type="text/plain"
			style="width:700px;height:250px;"></script></td>
	</tr>

	<tr>
		<td class="td_right"></td>
		<td class="">
		<div id="test" style="color: red;"></div>
		</td>
	</tr>
	<tr>
		<td class="td_right">&nbsp;</td>
		<td class=""><input type="button" class="btn btn82 btn_save2"
			onclick="onSub1();" value="保存"> <!-- <input type="submit" name="button" class="btn btn82 btn_save2" value="保存"> -->
		<input type="reset" name="button" class="btn btn82 btn_res" value="重置">
		</td>
	</tr>
</table>

</form>
<button onclick=" UE.getEditor('editor').setHeight(300)">设置富文本高度为300默认关闭了自动长高</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
	    function addPic(){
			$('#picDiv').append('<div class="clearfix" style="position:relative;height:40px;"><input style="width:280px;position:static;" onchange="checkPic(this)" type="file" name="img[]"/><a href="javascript:();" onclick="javascript:$(this).parent().remove();">移除</a><span class="required picError"></span></div>');
		}
	    function addCourse(){
			$('#courseDiv').append('<div class="clearfix" style="position:relative;height:40px;"><input style="width:280px;position:static;" onchange="checkPic(this)" type="test" name="two_course[]" class="input-text lh30"/><a href="javascript:();" onclick="javascript:$(this).parent().remove();">移除</a><span class="required picError"></span></div>');
		}
	 </script>
<script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');

    function isFocus(e){
        alert(UE.getEditor('editor').isFocus());
        UE.dom.domUtils.preventDefault(e)
    }
    function setblur(e){
        UE.getEditor('editor').blur();
        UE.dom.domUtils.preventDefault(e)
    }
    function insertHtml() {
        var value = prompt('插入html代码', '');
        UE.getEditor('editor').execCommand('insertHtml', value)
    }
    function createEditor() {
        enableBtn();
        UE.getEditor('editor');
    }
    function getAllHtml() {
        alert(UE.getEditor('editor').getAllHtml())
    }
    function getContent() {
        var arr = [];
        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
        arr.push("内容为：");
        arr.push(UE.getEditor('editor').getContent());
        alert(arr.join("\n"));
    }
    function getPlainTxt() {
        var arr = [];
        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
        arr.push("内容为：");
        arr.push(UE.getEditor('editor').getPlainTxt());
        alert(arr.join('\n'))
    }
    function setContent(isAppendTo) {
        var arr = [];
        arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
        UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
        alert(arr.join("\n"));
    }
    function setDisabled() {
        UE.getEditor('editor').setDisabled('fullscreen');
        disableBtn("enable");
    }

    function setEnabled() {
        UE.getEditor('editor').setEnabled();
        enableBtn();
    }

    function getText() {
        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
        var range = UE.getEditor('editor').selection.getRange();
        range.select();
        var txt = UE.getEditor('editor').selection.getText();
        alert(txt)
    }

    function getContentTxt() {
        var arr = [];
        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
        arr.push("编辑器的纯文本内容为：");
        arr.push(UE.getEditor('editor').getContentTxt());
        alert(arr.join("\n"));
    }
    function hasContent() {
        var arr = [];
        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
        arr.push("判断结果为：");
        arr.push(UE.getEditor('editor').hasContents());
        alert(arr.join("\n"));
    }
    function setFocus() {
        UE.getEditor('editor').focus();
    }
    function deleteEditor() {
        disableBtn();
        UE.getEditor('editor').destroy();
    }
    function disableBtn(str) {
        var div = document.getElementById('btns');
        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            if (btn.id == str) {
                UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
            } else {
                btn.setAttribute("disabled", "true");
            }
        }
    }
    function enableBtn() {
        var div = document.getElementById('btns');
        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
        }
    }

    function getLocalData () {
        alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
    }

    function clearLocalData () {
        UE.getEditor('editor').execCommand( "clearlocaldata" );
        alert("已清空草稿箱")
    }
</script>
<script type="text/javascript">
		//提交前执行
		function onSub1(){
			var course_name = $("input[name='course_name']").val();
			var two_course = $("input[name='two_course[]']").val();
			var price = $("input[name='price']").val();
			var sbprice = $("input[name='sbprice']").val();
			var img = $("input[name='img[]']").val();
			var editor = $("*[name='editor']").val();
		    var exp = /^([1-9][\d]{0,7}|0)(\.[\d]{1,2})?$/;
			//判断课程不能为空
			if(course_name == ""){
				$("#test").html("课程名称不能为空!");
				return false;
			}else{
				$("#test").html("");
			}
			//判断金额
		    if(!exp.test(price)){
		    	$("#test").html("金额不能为空或格式错误!");
				return false;
		    }else{
		    	$("#test").html("");
		    }
			//判断金额
		    if(!exp.test(sbprice)){
		    	$("#test").html("金额不能为空或格式错误!");
				return false;
		    }else{
		    	$("#test").html("");
		    }
			//判断报名须知不能为空
			if(editor == "" || typeof(editor) == "undefined"){
				$("#test").html("报名须知不能为空!");
				return false;
			}else{
				$("#test").html("");
			}
			$("#form").submit();
		}
	 </script>
</body>
